#ifndef CPP_PROJECT_GAME_H
#define CPP_PROJECT_GAME_H

#include "card.h"
#include "player.h"
#include "piles.h"
#include "constant.h"
#include <iostream>

class Player;
using namespace std;

class Game{
private:
    static unsigned int numOfPlayers;
    Player** players;
    Game();
    Game(const Game& game) = delete;
    Game& operator=(Game& game) = delete;
    static Game* instance;
public:
    static void setNumOfPlayers(unsigned int n) {
        if (n > 4) throw GameException("Wrong parameter: the number of players is between 2 and 4.");
        numOfPlayers = n;
    }
    static unsigned int getNumOfPlayers() {return numOfPlayers;}
    static Game& getInstance() {
        if(instance == nullptr)
            instance = new Game();
        return *instance;
    }
    static void deleteInstance() {
        delete instance;
        instance = nullptr;
    }
    Player** getPlayers() {return players;}
    Player & getPlayer(size_t i) const {  //提供获取玩家的接口
        if(i>numOfPlayers) throw GameException("Wrong parameter: the number of player not exist.");
        return *players[i];
    }
    ~Game();
};



#endif //CPP_PROJECT_GAME_H
